package com.jxsd.edu.cn.tools;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class Example 
{
      public  String   getHtml(String  url)
      {
    	  HttpClient   httpclient=new  DefaultHttpClient();
    	 String  inputHtml=null;
    	  try {
    	  HttpGet  httpget=new  HttpGet(url);
    	  
    	  System.out.println("excuting  requets "+httpget.getURI());
    	  //execute  the  get  request
    	  HttpResponse response;
    	  response = httpclient.execute(httpget);
    	  
			HttpEntity  entity=response.getEntity();
			if(entity!=null)
	    	  {
				inputHtml=EntityUtils.toString(entity);
	    	  }
			
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally
		{
			httpclient.getConnectionManager().shutdown();
		}
    	  return  inputHtml;
      }
}
